/*
 * 初始化easyui 框架
 * 修改mian中显示的链接
 * */
function initMenu() {
		var $subLink = $(".wg_menu").find("a");
		$subLink.click(function() {	
			var url = this.href;
			$('#wg_main').attr("src", url);
			return false;
		});
};

//登陆模块化窗口
var loginForm;
var loginDialog;

$(function(){
	initMenu();
	loginDialog = $('#loginDialog').dialog({
		closable:false,
		modal:true,
		buttons:[ {
			text:'登录',
			handler:function(){
				loginForm.submit();
			}
		}]
	});
	if ($.cookie("mgvlife_superadminname") != null) {
		loginDialog.dialog('close');
	}
	loginForm = $('#loginForm').form({
		url:'superadmin/superadmin_login',
		success:function(j){
			var json = $.parseJSON(j);
			if (json.result == "error") {
				$("input[name='password']").val('');
				$.messager.alert('Warning',json.data);
				return;
			} else if (json.result == "success") {
				$.messager.alert('Note',json.data);
				//将对话框隐藏掉
				loginDialog.dialog('close');
			} else {
				$.messager.alert('Warning','未知错误');
				return;
			}
		}	
	});
});
//扩展validatebox的验证规则
$.extend($.fn.validatebox.defaults.rules, {
	eqPassword: {
		validator: function(value, param){
			return value == $(param[0]).val();
		},
		message: '两次密码不一致'
	}
});